package com.wx.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.wx.dao.AddOrderDao;
import com.wx.model.Order;
import com.wx.util.DBUtil;

public class AddOrderDaoImpl implements AddOrderDao {

	public void addOrder(Order order) throws Exception {
		Connection conn = DBUtil.getConnection();
		PreparedStatement ps = conn.prepareStatement("insert into order(bookid,userid,name,phone,home,postcode,ordertime,bookcount,count) values(?,?,?,?,?,?,now(),?,?");
		ps.setInt(1, order.getBookid());
		ps.setInt(2, order.getUserid());
		ps.setString(3, order.getName());
		ps.setString(4, order.getPhone());
		ps.setString(5, order.getHome());
		ps.setInt(6, order.getPostcode());
		ps.setInt(7, order.getBookcount());
		ps.setDouble(8, order.getCount());
		ps.executeUpdate();
		
		ps.close();
		conn.close();
		
	}

}
